<template>
  <div>
    <el-form
        ref="dicTypeForm"
        :rules="rules"
        :model="dicTypInfo"
        label-position="right"
        label-width="120px"
      >
        <el-row>
          <el-col :span="10">
            <el-form-item label="🍁货物名称">
              <el-input v-model="dicTypInfo.m_name"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="🍁类型">
              <el-input v-model="dicTypInfo.m_kind"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="10">
            <el-form-item label="🍁材质">
              <el-input v-model="dicTypInfo.m_texture"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="规格">
              <el-input v-model="dicTypInfo.m_specification"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="10">
            <el-form-item label="🍁数量">
              <el-input v-model="dicTypInfo.m_num"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="🍁单价">
              <el-input v-model="dicTypInfo.m_price"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="10">
            <el-form-item label="审批人">
              <el-input v-model="dicTypInfo.m_proposer"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="15">
            <el-form-item label="备注">
              <el-input
                type="textarea"
                v-model="dicTypInfo.m_remark"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    <div slot="footer" class="dialog-footer">
      <!-- dialogStatus === '1' 是添加 就执行添加的方法  是修改  就执行修改的方法-->
      <el-button type="primary" @click="addDictType()">
        保存
      </el-button>
      <el-button> 取消 </el-button>
    </div>
  </div>
</template>

  <script>
import { dttCreated } from "@/api/system_base/stock_manager";

export default {
  data() {
    return {
      dialogStatus: "1", // 等于1 表示是添加操作   不等于1 表示修改操作
      dicTypInfo: {},
    };
  },
  created() {
    this.resetDicinfo();
  },
  methods: {
    addDictType() {
      if(this.dicTypInfo.m_name=="") 
       {
         this.$message("货物名称不能为空");
         return;
       }
       if(this.dicTypInfo.m_fuqian=="") 
       {
         this.$message("支付方式不能为空");
         return;
       }
       if(this.dicTypInfo.m_num=="") 
       {
         this.$message("数量不能为空");
         return;
       }
       if(this.dicTypInfo.m_texture=="") 
       {
         this.$message("材质不能为空");
         return;
       }
       if(this.dicTypInfo.m_price=="") 
       {
         this.$message("单价不能为空");
         return;
       }
       if(this.dicTypInfo.m_kind=="") 
       {
         this.$message("货物类型不能为空");
         return;
       }
      //添加方法
      this.$refs["dicTypeForm"].validate((valid) => {
        if (valid) {
          dttCreated(this.dicTypInfo).then((response) => {
            this.$router.push("/ruku");
            this.$notify({
              title: "添加成功",
              message: "添加物资信息成功",
              type: "success",
              duration: 2000,
            });
          });
        }
      });
    },
    resetDicinfo() {
      // 初始化用户对象
      this.dicTypInfo = {
        m_name: "",
        m_kind: "",
        m_texture: "",
        m_specification: "",
        m_num: "",
        m_price: "",
        m_remark: "",
        m_proposer:"",
      };
    },
  },
};
</script>

<style >
.search_input {
  width: 200px;
}
</style>